<template>
  <div class="article-detail">
    <div class="article-header">
      <img v-if="article.icon" :src="article.icon" class="article-icon" />
      <div>
        <h1 class="article-title">{{ article.title }}</h1>
        <div class="article-meta">
          <span>{{ getCategoryNameById(article.category, categoriesTree) }}</span>
          <span style="margin-left: 16px; color: #888;">{{ article.updatedAt }}</span>
        </div>
      </div>
    </div>
    <div class="article-content" v-html="article.content" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import { useRoute } from 'vue-router'
import { list, categoriesTree, getCategoryNameById } from './copywriting-data'
const route = useRoute()
const id = Number(route.params.id)
const article = list.value.find(i => i.id === id) || { title: '', content: '', category: 0, icon: '', updatedAt: '' }
</script>

<style scoped>
.article-detail {
  max-width: 600px;
  margin: 40px auto;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.08);
  padding: 32px 24px;
}
.article-header {
  display: flex;
  align-items: center;
  margin-bottom: 24px;
}
.article-icon {
  width: 60px;
  height: 60px;
  object-fit: contain;
  border-radius: 8px;
  margin-right: 20px;
}
.article-title {
  font-size: 2rem;
  margin: 0 0 8px 0;
}
.article-meta {
  color: #888;
  font-size: 14px;
}
.article-content {
  margin-top: 24px;
  font-size: 1.1rem;
  line-height: 1.8;
}
</style> 